<template class="firstpage">
  <div>
    <div id="tab" class="boxMargin">
      <el-tabs v-model="customData.activeName" type="border-card" :before-leave="beforeLeave">
        <el-tab-pane label="基本信息" name="first">
          <BASICPLUGINS v-if="customData.basic" ref="basic" @child-event="getDate" />
        </el-tab-pane>
        <el-tab-pane label="商品描述" name="second">
          <DESCPLUGINS v-if="customData.desc" ref="desc" />
        </el-tab-pane>
        <el-tab-pane label="商品图片" name="third">
          <IMAGEPLUGINS v-if="customData.image" ref="image" />
        </el-tab-pane>
        <el-tab-pane label="分类属性" name="fourth">
          <ATTRPLUGINS v-if="customData.categoryAttr" ref="categoryAttr" />
        </el-tab-pane>
        <el-tab-pane label="商品视频" name="fifth">
          <VIDEOPLUGINS v-if="customData.videoModel" ref="videoModel" />
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>
<script>
import $ from 'jquery'
import _validate from '../../../../../framework/commonJs/wptx_validate'
import _tools from '../../../../../framework/commonJs/wptx_tools'
import _common from '../../../../../framework/commonJs/wptx_common'
import BASICPLUGINS from './item_create_basic_plugins.vue'
import IMAGEPLUGINS from './item_create_image_plugins.vue'
import DESCPLUGINS from './item_create_desc_plugins.vue'
import VIDEOPLUGINS from './item_create_video_plugins.vue'
import ATTRPLUGINS from './item_create_attr_plugins.vue'
const _FUNCTION_NAME = ''
export default {
  components: {
    BASICPLUGINS: BASICPLUGINS,
    IMAGEPLUGINS: IMAGEPLUGINS,
    DESCPLUGINS: DESCPLUGINS,
    VIDEOPLUGINS: VIDEOPLUGINS,
    ATTRPLUGINS: ATTRPLUGINS
  },
  filters: {},
  data() {
    return {
      tableData: [],
      searchData: {
      },
      searchDataBuffer: {
      },
      pageData: {
        pageNo: 1,
        pageSize: 10,
        total: 1,
        pageSizes: [10, 20, 50, 100]
      },
      dialogData: {},
      historyData: {},
      infoData: {},
      customData: {
        activeName: 'first',
        basic: true,
        image: false,
        desc: false,
        videoModel: false,
        categoryAttr: false,
        itemId: '',
        versionId: ''
      },
      form: {},
      rules: {}
    }
  },
  computed: {},
  watch: {},
  created() { },
  mounted() {
    this._FUNCTION_NAME = this.$route.name
    this.onInit()
  },
  beforeDestroy() { },
  methods: {
    onInit(data) {
      const self = this
    },
    onSearch(data) {
      const self = this
    },
    onChangePage(data) {
      const self = this
    },
    onReset(data) {
      const self = this
    },
    onAdd(data) { },
    onDelete(data) {
      const self = this
    },
    onInfo(data) {
      const self = this
    },
    onUpdate(formName) {
      const self = this
    },
    onBathDelete() {
      const self = this
    },
    onBathUpdate() { },
    onDisable(data) {
      const self = this
    },
    onEnable(data) {
      const self = this
    },
    onUpload(data) { },
    onBathUpload() { },
    onExport(data) { },
    onDownload(data) { },
    onHistory(data) { },
    callBack_page(data) {
      const self = this
      if (_validate.checkEmpty(data)) {
        _validate.openTip(self, '返回数据为空', 'warning')
      } else { }
    },
    getDate(itemId, versionId) {
      const self = this
      self.customData.itemId = itemId
      self.customData.versionId = versionId
    },
    beforeLeave(activeName, oldActiveName) {
      const self = this
      const itemId = sessionStorage.getItem('itemId')
      const p = new Promise((resolve, reject) => {
        if (itemId != undefined && itemId != null && itemId != '') {
          if (activeName == 'first') {
            self.customData.basic = true
            self.customData.image = false
            self.customData.desc = false
            self.customData.video = false
            self.customData.categoryAttr = false
          } else if (activeName == 'second') {
            self.customData.basic = false
            self.customData.image = false
            self.customData.desc = true
            self.customData.videoModel = false
            self.customData.categoryAttr = false
          } else if (activeName == 'third') {
            self.customData.basic = false
            self.customData.image = true
            self.customData.desc = false
            self.customData.videoModel = false
            self.customData.categoryAttr = false
          } else if (activeName == 'fourth') {
            self.customData.basic = false
            self.customData.image = false
            self.customData.desc = false
            self.customData.videoModel = false
            self.customData.categoryAttr = true
          } else if (activeName == 'fifth') {
            self.customData.basic = false
            self.customData.image = false
            self.customData.desc = false
            self.customData.videoModel = true
            self.customData.categoryAttr = false
          }
          resolve()
        } else {
          reject(err)
        }
      })
      return p
    }
  }
}
</script>
